<?php
/**
 * Created by PhpStorm.
 * User: wangwenshan
 * Date: 2019/1/21
 * Time: 15:19
 */

namespace app\api\model;


class Theme extends BaseModel
{
    protected $hidden = ['topic_img_id','head_img_id','delete_time','update_time'];
    public function topicImg(){
        //$this->hasOne()
        return $this->belongsTo('Image','topic_img_id','id');
    }
    public function headImg(){
        return $this->belongsTo('Image','head_img_id','id');
    }
    public function products(){
        return $this->belongsToMany('Product','theme_product','product_id','theme_id');
    }
//    public function getThemeWithProducts($id){
//        $theme = self::with('products,topicImg,headImg')->find($id);
//        return $theme;
//    }
}